<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function objectFlat(obj = {}) {
        const res = {}

        function flat(item, preKey = '') {
            Object.entries(item).forEach(([key, val]) => {
                const newKey = preKey ? `${preKey}.${key}` : key
                if (val && typeof val === 'object') {
                    flat(val, newKey)
                } else {
                    res[newKey] = val
                }
            })
        }

        flat(obj)
        return res
    }

    const data = {a: {b: {c: 1, d: 2}, e: 3}, f: {g: 2}, b: 1,c:[1,2,3]}
    console.log(objectFlat(data));
</script>
</body>
</html>